<div id="content">
	
</div>
<table id="tb" border="1" style='border-collapse:collapse;width:300px;'>
	
</table>
<hr>
<input type="text" id="txtUserName" /><br/>
<input type="text" id="txtPassword" /><br/>
<button onclick="addAccount()">Add</button>
<script>
	var webSocket = new WebSocket("ws://localhost:8080/ishare/ws/manageaccount");
	
	function addAccount(){
		var data = {
				"id":"0",
				"username":$("#txtUserName").val(),
				"password":$("#txtPassword").val(),
		};
		//clear
		$("#txtUserName").val("");
		$("#txtPassword").val("");
		
		var stringData = JSON.stringify(data); 
		webSocket.send(stringData);
		return false;
	}
	
	webSocket.onmessage = function(evt){
		$("#tb tr").remove();
		var data = $.parseJSON(evt.data);
		for(var i=0;i<data.length;i++){
			var tr ="<tr>" +
						"<td>"+data[i].id+"</td>" +
						"<td>"+data[i].username+"</td>" +
						"<td>"+data[i].password+"</td>" +
					"</tr>";
			$("#tb").append(tr);
		}
		
	};
</script>

